home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
passwrd9.zip
/
PWINT.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-03-15
|
14KB
|
443 lines
;============================================================================
; Title - PWINIT DATE: 3/15/89
; This program is used with PASSWORD.ASM
; and its resulting file PASSWORD.BIN after
; compiling with MASM and converting it
; to a binary image file using EXE2BIN.EXE.
;
; The resulting EXE file will take an uninitialized
; PASSWORD.BIN file and insert the password of
; your choice and then encode the resulting
; PASSWORD.SYS file to transfer under whatever
; name you desire (as long as the name in CONFIG.SYS
; matches ie:DEVICE=PASSWORD.SYS) to your boot disk.
; I would suggest using a different name to conceal
; your intentions!
;============================================================================
Dos equ 21h
;============================================================================
code segment ; Define code segment
;============================================================================
main proc far
assume cs:code,ds:data,es:file
start: ; Main starting address
; Set ds to our data segment
mov ax,data ;Data segment address
mov ds,ax ;Move into ds register
mov ax,file ;Get File segment
mov es,ax ;Set es: to file segment
call check_video ;See what type of monitor
mov dx,offset org_file_name ;Point to Uninit file name
call open_file ;Open file for read only
mov old_handle,ax ;Store the handle
mov bx,ax ;Set up for read
mov dx,offset ds:file_buffer ;Point to file buffer area
mov cx,800h ;Set number of characters
push bx ;Save the file handle
call read_file ;Read file into buffer
mov file_size,ax ;Store number of bytes in file
pop bx ;Restore the file handle
call close_file ;Close the old file
call clear_screen ;Clear the CRT
call input_word ;Ask user for PASSWORD
call box ;Clear the entry box
call off_screen ;Get cursor out of box
mov ax,word ptr ds:file_buffer+22 ;Get count of char to encode
mov scramble_count,ax ;Store it for later
mov ax,offset es:file+24 ;Point to PASSWORD address
mov pass_location,ax ;Store the offset
mov di,ax ;Move offset to di
push di ;Save it for the moment
xor cx,cx ;Zero the counter
mov cl,password+1 ;Get user entered char. count
inc cl ;Account for char. count
mov ax,offset password+1 ;Point to user password
mov si,ax ;Move pointer into si
rep movsb ;Move the PASSWORD into the
;new file area
pop di ;Restore es:offset to new
;file password area
mov cx,scramble_count ;Load the char count to encode
push ds ;Save original data segment
push es
pop ds ;Make ds=es
mov si,di ;Make di & si point to the
scramble: ;same bytes
lodsb ;Get a byte
sub al,40h ;Remove 40h
stosb ;Store the byte
loop scramble ;Loop until done
pop ds ;Restore the original ds
mov dx,offset new_file_name ;Point to the new file name
call create_file ;Create it
mov bx,ax ;Get the file handle into bx
push bx ;Save it
mov cx,file_size ;Load the cx with the file
;size
mov dx,offset ds:file_buffer ;Point to the file buffer
call write_file ;Write the new file
pop bx ;Restore the file handle
call close_file ;Close the new file
mov ah,8fh ;Set attribute for display
mov bx,offset msg_4 ;Point to the complete msg.
mov cx,msg_4_len ;Length of message
mov dx,0d1ch ;Location to write it
call write_crt ;Display message
done:
mov ax,4c00h
int dos ;Return to DOS
main endp ;End of main program
;============================================================================
check_video proc near ;See where video RAM is
mov ah,0fh ;via video ROM
int 10h
cmp al,07h ;See if Mono card installed
jz set_mono ;Jump to monochrome routine
mov video_location,0b800h ;If not mono then Color RAM
jmp video_done ;Exit routine
set_mono:
mov video_location,0b000h ;Set location to Mono RAM
video_done:
ret
check_video endp
;============================================================================
;The following routines are the direct CRT display code
;============================================================================
write_crt proc near
push es ;Save original es
push dx ;Save location to write
push ax ;Save the attribute
push cx ;Save the character count
push dx ;Save for the moment
mov cx,02h ;Set the multiplier
mov ax,video_location ;Get the address of video RAM
mov es,ax ;Set the es register to RAM
mov si,bx ;Point si to the message
xor ax,ax ;Zero the ax
mov al,dl ;Move to al the column
sub al,1 ;Adjust the al
imul cx ;Times to for actual column
pop dx ;Get the original location
mov dl,al ;Store column in dl
mov al,dh ;Move into ax the row
push dx ;Save for the moment
sub ax,1 ;Adjust the ax
mov cx,160 ;80 times 2 for actual offset
imul cx
pop dx ;Get dx back
and dh,00h ;Zero the dh
add ax,dx ;Add the column offset to the
mov di,ax ;row and move di to the actual
;memory position
pop cx ;Restore character count
pop ax ;Restore the attribute
write_crt_1:
lodsb ;Load a byte of message
stosw ;Store byte & attribute to RAM
loop write_crt_1 ;Loop until cx=0
pop dx ;Restore original dx
pop es ;restore original es
ret ;And return
write_crt endp
;============================================================================
write_cursor proc near
off_screen:
xor bx,bx ;Zero bx (page 0) and set
xor dx,dx ;position to upper left corner
position_cursor:
mov ah,02h ;Have DOS reset the cursor
int 10h ;where we want it
ret ;And return
clear_screen:
mov ax,0600h ;Use DOS scroll to clear CRT
mov bh,07 ;Set attribute
xor cx,cx ;Upper left corner 0,0
mov dx,184fh ;Lower right 24,79
int 10h
ret ;And return
write_cursor endp
;============================================================================
;Area to get the user password
;============================================================================
input_word proc near
call box ;Make input display box
mov ah,0fh ;Set attribute for display
mov bx,offset msg_1 ;Point to opening mess.
mov cx,msg_1_len ;Set message length
mov dx,0d19h ;Location on CRT
call write_crt ;Display it
mov dx,0c27h ;Address for cursor
xor bx,bx ;Zero bx : Page 0
call position_cursor ;set cursor to entry position
mov ax,0c0ah ;Set up to use DOS buffer
mov dx,offset password ;input routine (point to
;our buffer
int DOS ;Get input string
call box ;Clear the box
mov ah,0fh ;Load attribute
mov bx,offset msg_2 ;Point to next message
mov cx,msg_2_len ;Load the length
mov dx,0c19h ;Load where to display it
call write_crt ;Write the display
xor cx,cx ;Zero the count register
mov cl,password+1 ;Load # of char entered
mov bx,offset password+2 ;Point to the string
mov dx,0c27h ;Address to display
mov ah,8fh ;Load attribute
call write_crt ;Display entered password
;for conformation
mov ah,0fh ;Load attribute
mov bx,offset msg_3 ;Point to confirm message
mov cx,msg_3_len ;Length
mov dx,0e19h ;Location for display
call write_crt ;Display message
char_loop:
mov dx,0d33h ;Location for cursor
xor bx,bx ;Page 0
call position_cursor ;Position cursor for input
;of a Y or N answer
mov ah,0ah ;Write a blank at the cursor
mov al,' ' ;to erase a answer that is
mov cx,01h ;not a Y or N
int 10h
mov ah,01h ;Get one character
int DOS
and al,5fh ;Convert to upper case
cmp al,'Y' ;If PASSWORD confirmed then
je ok ;jump to a return
cmp al,'N' ;If not, then ask for new
je input_word ;password
mov ax,0e07h ;If neither then ring bell
int 10h ;and ask for Y or N
jmp char_loop
ok: ret ;PASSWORD ok. Set up
;PASSWORD.SYS
input_word endp
;====================================